package com.dongbo.recorder.screenrecord.dialog;

/**
 * Created by Administrator on 2017-12-01.
 */

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;

import com.dongbo.recorder.screenrecord.R;

import butterknife.ButterKnife;
import butterknife.OnClick;

public class CancelDialog extends Dialog {

    private OnDialogEventListener onDialogEventListener;
    private Context context;

    /**
     * @param context
     * @param themeResId
     * @param onDialogEventListener dialog 事件回调
     */
    public CancelDialog(Context context,
                        int themeResId,
                        OnDialogEventListener onDialogEventListener) {
        super(context, themeResId);
        this.context = context;
        this.onDialogEventListener = onDialogEventListener;
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_dialog_cancle);
        ButterKnife.bind(this);
    }

    @OnClick({R.id.btnCancel, R.id.xuzhi,})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btnCancel:
                if (onDialogEventListener != null) {
                    onDialogEventListener.onCancel();
                }
                dismiss();
                break;
            case R.id.xuzhi:
                if (onDialogEventListener != null) {
                    onDialogEventListener.onShow();
                }
                break;
        }
    }

    public interface OnDialogEventListener {
        void onCancel();

        void onShow();
    }

    public void destroy() {
        onDialogEventListener = null;
        context = null;
        dismiss();
        cancel();
    }

}